﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace lazy
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        static string Name;
        static string Password;
        protected void Page_Load(object sender, EventArgs e)
        {

            Name = Request.QueryString["name"];
            Password = Request.QueryString["password"];

        }

        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (TextBox1.Text.Equals(Name) || Name != null)
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }

        protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (args.Value == "admin")
            {
                CustomValidator2.IsValid = true;
            }
        }

        protected void CustomValidator3_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (CustomValidator3.Text.Equals(Name) || Name != null)
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }

        protected void CustomValidator4_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (TextBox2.Text.Equals(Password) || Password != null)
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            Response.Write(Name + "," + Password);
            if (TextBox2.Text == Password && TextBox1.Text == Name)
            {
                Literal1.Text = $"登录成功 <a href=\"WebForm3.aspx?name={Name}\">进入</a>";
            }
            else
            {
                Literal1.Text = "出错";
            }
        }
    }
}